﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using log4net.Core;
using Microsoft.AspNetCore.Mvc;
using MKAdminCore.Controllers;
using MKAdminCore.IService.Web.Organization;
using log4net;
using Microsoft.Extensions.Logging;
using ILogger = Microsoft.Extensions.Logging.ILogger;

namespace MKAdminCore.Areas.Organization.Controllers
{
    [Area("Organization")]
    [Route("Organization/[controller]/[action]")]
    public class PermissionSettingController : BaseMvcController
    {
        private IPermissionSettingService _iPermissionSettingService;
        private ILogger _iLogger;

        public PermissionSettingController(IPermissionSettingService iPermissionSettingService, ILogger<PermissionSettingController> iLogger)
        {
            _iPermissionSettingService = iPermissionSettingService;
            _iLogger = iLogger;
        }
        public IActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 获取用户菜单权限信息
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult PermissionMenuList()
        {
            var userInfo = base.GetUserInfo();

            var result = _iPermissionSettingService.PermissionMenuList(userInfo);

            return Ok(result);
        }

        /// <summary>
        /// 获取用户菜单权限信息
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> PermissionFunctionList(int rightId)
        {
            var userInfo = base.GetUserInfo();

            var result = await _iPermissionSettingService.PermissionFunctionList(rightId, userInfo);

            return Ok(result);
        }
    }
}